package com.aat.dxfy.protobuf.test2;

import java.io.IOException;

import com.aat.dxfy.protobuf.test1.proto.Mobile;
import com.aat.dxfy.protobuf.test1.proto.Mobile.MobilePhone;

public class TestProtoBuf {

	public static void main(String[] args) throws IOException {
		// 序列化过程

		Mobile.MobilePhone.Builder builder = Mobile.MobilePhone.newBuilder();
		builder.setBrand("123");
		Mobile.Hardware.Builder hardware = Mobile.Hardware.newBuilder();
		hardware.setRam(2).setRom(16).setSize(5);
		builder.setHardware(hardware);
		byte[] messageBody = builder.build().toByteArray();

		MobilePhone tb = MobilePhone.parseFrom(messageBody);
		System.out.println(tb.getBrand());
	}
}